<?php

namespace App\Http\Controllers\Admin;
use Illuminate\Support\Facades\Input;

require_once 'resources/org/code/Code.class.php';

class LoginController extends CommonController {
    //
    public function login() {
        if ($input = Input::all()) {
            if (strtoupper($input['captcha']) != $this->captchaValue()) {
                return back()->with('msg','验证码错误！');
            }
        } else {
            return view('admin.login');
        }
    }

    public function doLogin() {
        if (!$input = Input::all()) {
            return "未设置";
        }
        if ($input['captcha'] != $this->captchaValue()) {
            return "验证码错误";
        }
    }

    public function crypt() {
        \Crypt::encrypt("1234");

    }

    private $captcha;

    public function captcha() {
        $this->captcha = new \Code();
        $this->captcha->make();
    }

    public function captchaValue() {
        if (!isset($this->captcha)) {
            $this->captcha = new \Code();
        }
        return $this->captcha->get();
    }

}
